<template>
	<view class="question">
		<u-parse :content="content ? content : '无'"></u-parse>
		<view v-if="showSelect" class="answer-list">
			<AnswerSelect
				:type="type"
				:result="result"
				:questionList="questionList"
				:answerList="answerList"
				:correctAnswerList="correctAnswerList"
				@submit="handleSubmit"></AnswerSelect>
		</view>
		<view v-else-if="type == 'question' && !result" class="submit-button">
			<u-button type="primary" shape="circle" text="查看答案" @click="handleSubmit"></u-button>
		</view>
	</view>
</template>

<script>
import AnswerSelect from './answerSelect'
export default {
	components: {
		AnswerSelect
	},
	props: {
		code: {
			type: String,
			require: true
		},
		type: {
			type: String,
			require: true
		},
		result: String,
		content: {
			type: String,
			require: true
		},
		questionList: Array,
		answerList: Array,
		correctAnswerList: Array
	},
	computed: {
		showSelect() {
			return ['single', 'multiple'].includes(this.type)
		}
	},
	methods: {
		handleSubmit(data) {
			this.$emit('submit', {code: this.code, values: data})
		}
	}
}
</script>

<style lang="scss" scoped>
	.question {
		padding: 30rpx 0rpx 20rpx;
	}
	.submit-button {
		padding: 30rpx 0rpx 0rpx;
	}
</style>